package com.ruoyi.consumer.utils.pay;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class OrderNumberGenerator {
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
    private static final Random random = new Random();

    public static String generateOrderNumber() {
        String timestamp = dateFormat.format(new Date());
        String randomDigits = getRandomDigits(6); // 生成6位随机数字
        return "ZSKY-" + timestamp + randomDigits;
    }

    //生成退款订单号
    public static String generateRefundOrderNumber() {
        String timestamp = dateFormat.format(new Date());
        String randomDigits = getRandomDigits(6); // 生成6位随机数字
        return "RZSKY-" + timestamp + randomDigits;
    }

    private static String getRandomDigits(int length) {
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < length; i++) {
            result.append(random.nextInt(10)); // 生成随机数字
        }
        return result.toString();
    }

    public static void main(String[] args) {
        String orderNumber = generateOrderNumber();
        System.out.println("Generated Order Number: " + orderNumber);
    }
}
